<%@page pageEncoding = "utf-8" contentType = "text/html;charset=utf-8"%>

<%@taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix = "fn" uri = "http://java.sun.com/jsp/jstl/functions"%>

<h2><fmt:message key = "subordinateListForm.title"/></h2>

<div class = "messages"><jsp:include page = "/messages.jsp"/></div>

<table width="100%" cellpadding="10" cellspacing="10">
      <thead>
         <tr>            
           <th>#</th>                        
           <th><fmt:message key = "employee.lastName"/></th>                        
           <th><fmt:message key = "employee.group"/></th>
           <th><fmt:message key = "employee.type"/></th>
           <th><fmt:message key = "employee.operations"/></th>
         </tr>
      </thead>

      <tbody>
           <c:forEach var = "employee" items = "${employessList}">
            <tr>               
               <td><c:out value = "${employee.id}"/></td>               
               <td><c:out value = "${employee.formName}"/></td>               
               <td><c:out value = "${employee.group.name}"/></td>
               <td><c:out value = "${employee.type.name}"/></td>
               <td>
                 <a href = "adminui?_action=manageSubordinate&employee_id=${employee.id}&owner_id=${owner}&action=delete"
                    onclick="return confirm('Вы действительно хотите освободить подчиненного?')"
                 >
                   <fmt:message key = "employee.operations.remove"/>
                 </a>
               </td>
            </tr>
         </c:forEach>

        <c:if test="${fn:length(employessList) == 0}">              
          <tr><td colspan = "5" align="center"><fmt:message key="emptyList"/></td></tr>
        </c:if>
      </tbody>
</table>

<div id="box">
<form action = "adminui" method = "post" name = "addSubordinate">

<table class = "form">      
   <tr>
      <td class = "label"><fmt:message key = "employee"/></td>      
         <td>
            <select name="employee_id">
              <c:forEach var = "subordinate" items = "${subordinatesList}">
                <option value="${subordinate.id}">${subordinate.formName}</option>
              </c:forEach>
            </select>            
            <span class="error"><c:out value="${error.type}"/></span>
         </td>
   </tr>
</table>
  
<input name = "_action" type = "hidden">   
<input name = "action" type = "hidden" value="manageSubordinate">
<input name = "owner_id" type = "hidden" value='<c:out value = "${owner}"/>'>   

<p>
  <input type="submit" value='<fmt:message key = "Command.add"/>'>
</p>

</form>
</div>